<?php
// JSON
function prepareJSON($input) {
   
    //This will convert ASCII/ISO-8859-1 to UTF-8.
    //Be careful with the third parameter (encoding detect list), because
    //if set wrong, some input encodings will get garbled (including UTF-8!)
    $imput = mb_convert_encoding($input, 'UTF-8', 'UTF-8');
   
    //Remove UTF-8 BOM if present, json_decode() does not like it.
    if(substr($input, 0, 3) == pack("CCC", 0xEF, 0xBB, 0xBF)) $input = substr($input, 3);
   
    return $input;
}

// print + enter
function println($str){
	print $str.'<br/>';
}

// 写游戏纪录
function writeGameLog($fileName,$msg) {
	$file=fopen($fileName,"r+") or exit("Unable to open file!");
	clearstatcache();
	$fp = filesize($fileName)-2;
	$text = ",{\"text\":\"".$msg."\"}]}";
	fseek($file,$fp);
	fwrite($file,$msg);
	fclose($file);
}

?>